Fix category rules regressions from the contextual Category rules section - #97729
Conversation
…tion Signed-off-by: krishna2323 <belivethatkg@gmail.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8b1f329d57
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
…rules test Signed-off-by: krishna2323 <belivethatkg@gmail.com>
Signed-off-by: krishna2323 <belivethatkg@gmail.com>
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppAndroid: mWeb ChromeiOS: HybridAppiOS: mWeb SafariMacOS: Chrome / Safari97560.mov97561.mov97563.mov |
ReviewLooks solid — the three fixes are well-scoped and each mirrors an existing, proven pattern. All CI is green (ESLint, typecheck, all What I verifiedFix #3 (pending-delete Field requirements stay visible) — Fix #2 (deleted rules non-interactive) — Fix #1 (prefill existing settings) — the codex-flagged async-load case (deep-link/refresh before
Minor (optional): On the MenuItem you pass both I reviewed the code and CI only; I didn't run the beta-gated offline flows live. The added unit tests in |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4a4c4c9a3d
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| // really an edit. Passing categoryName seeds the amount from the category instead of opening it empty, which | ||
| // would otherwise overwrite the existing rule on save. initialCategoryName stays set so saving still returns | ||
| // to the category details page rather than the New rule hub we came from. | ||
| const hasExistingRule = !!scopedCategory && hasExplicitFlagAmount(scopedCategory.maxExpenseAmount); |
There was a problem hiding this comment.
Exclude pending deletes before editing an existing flag
When a flag-for-review rule is deleted while offline, the optimistic category keeps the old maxExpenseAmount while marking pendingFields.maxExpenseAmount as DELETE, so hasExplicitFlagAmount() still makes hasExistingRule true here. From the category page the disabled struck-through row can therefore be bypassed via Create new rule > Flag for review, which opens the pending-deleted rule in edit mode and lets a save requeue it instead of starting a fresh create. Please treat pending-delete flags as non-existing (or keep the create option disabled for that rule) before passing categoryName into the base page.
Useful? React with 👍 / 👎.
|
🚧 JS00001 has triggered a test Expensify/App build. You can view the workflow run here. |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
Explanation of Change
This PR fixes three regressions introduced by the contextual Category rules section in the category details RHP.
1. Creating a rule didn't preload existing category settings
Creating a new Field requirements or Flag for review rule opened an empty form, even when the category already had that rule.
Since both rule types are limited to one per category, re-selecting the same values counted as no change:
The Add pages now pass
categoryNamewhenever the category already has that rule, so the form is prefilled the same way as when editing from the category RHP. They continue passinginitialCategoryName, so saving still returns to the category details page instead of the New rule hub.2. Optimistically deleted rules remained interactive
Rules pending deletion could still be opened.
Both rule types now expose
isDisabledwhenpendingAction === DELETE, making the menu item non-interactive and removing the chevron.3. Pending-delete Field requirements disappeared
A deleted Field requirements rule disappeared instead of remaining visible with a strikethrough.
getCategoryContextualRulesnow mirrorsgetRequireFieldsTableData:shouldIncludePendingDeleteFieldsso the summary continues to render.Fixed Issues
$ #97560
$ #97561
$ #97563
PROPOSAL:
Tests
#97560 Rules - "Please select at least one field" is shown when all fields are selected
Offline tests
#97561 Rules - Deleted flag for review rule can be opened in offline mode
#97563 Rules - Deleted field requirements rule disappears instead of showing crossed-out in offline
QA Steps
Same as tests
Verify that no errors appear in the JS console
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectioncanBeMissingparam foruseOnyxtoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
web_chrome.mp4